package hfjava;

public class Dog {
    //属性
    private String name;
    private char sex;
    private String kinds;
    private int age;

    //方法

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
       if (sex=='雄'||sex=='雌'){
           this.sex=sex;
       }else{
           this.sex='雄';
           System.out.println("输入错误");
       }
    }

    public String getKinds() {
        return kinds;
    }

    public void setKinds(String kinds) {
        this.kinds = kinds;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //构造

    public Dog(String name, char sex, String kinds, int age) {
        this.name = name;
         setSex(sex);
        this.kinds = kinds;
        this.age = age;
    }
    public void shot(){
        System.out.println("我会叫");
    }
    public void run(){
        System.out.println("我会跑");
    }

    public static void main(String[] args) {
        Dog dog=new Dog("嘟嘟",'雄',"拉布拉多",3);
        dog.run();
        dog.shot();

    }
}
